import {ServicePrefixEnum} from "@/enums/commonEnum";
import {RequestEnum} from "@/enums/httpEnum";
import {defHttp} from "@/utils/http/axios";
import type { AxiosRequestConfig } from 'axios';


export interface NoticeVO {
  id: number | undefined
  title: string
  type: number
  content: string
  status: number
  remark: string
  creator: string
  createTime: Date
}
const  MODULAR = '/system/notice'
export const Api = {
  GetNoticePage: {
    url: `${ServicePrefixEnum.BASE}/${MODULAR}/page`,
    method: RequestEnum.GET,
  } as AxiosRequestConfig,

  GetNotice: {
    url: `${ServicePrefixEnum.BASE}/${MODULAR}/get`,
    method: RequestEnum.GET,
  } as AxiosRequestConfig,
  CreateNotice: {
    url: `${ServicePrefixEnum.BASE}/${MODULAR}/create`,
    method: RequestEnum.POST,
  } as AxiosRequestConfig,
  UpdateNotice: {
    url: `${ServicePrefixEnum.BASE}/${MODULAR}/update`,
    method: RequestEnum.PUT,
  } as AxiosRequestConfig,
  DeleteNotice: {
    url: `${ServicePrefixEnum.BASE}/${MODULAR}/delete`,
    method: RequestEnum.DELETE,
  } as AxiosRequestConfig,
  PushNotice: {
    url: `${ServicePrefixEnum.BASE}/${MODULAR}/push`,
    method: RequestEnum.POST,
  } as AxiosRequestConfig,
}

// 查询公告列表
export const getNoticePage = (params: PageParam) => {
  return defHttp.request({ ...Api.GetNoticePage,params })
}

// 查询公告详情
export const getNotice = (id: number) => {
  let params = { id: id }
  return defHttp.request({ ...Api.GetNotice,params })
}

// 新增公告
export const createNotice = (data: NoticeVO) => {
 let params = { data: data}
  return defHttp.request({ ...Api.CreateNotice,params:params })
}

// 修改公告
export const updateNotice = (data: NoticeVO) => {
  let params = { data: data}
  return defHttp.request({ ...Api.UpdateNotice,params:params })
}

// 删除公告
export const deleteNotice = (id: number) => {
  let params = { id: id}
  return defHttp.request({ ...Api.DeleteNotice,params:params })
}

// 推送公告
export const pushNotice = (id: number) => {
  let params = { id: id}
  return defHttp.request({ ...Api.PushNotice,params:params })
}
